Speed up OR search, fd filename search, and preview#30
Merged
Conversation
- OR content search now runs as a single ripgrep process using multiple -e patterns, traversing the filesystem once instead of once per keyword. rgSearchArgs accepts a keyword array; -e also guards patterns starting with '-'. - fd filename search runs all keywords concurrently (Promise.all) to overlap filesystem I/O. - Preview build reads files asynchronously (fs.promises) so the main process is not blocked; lowercases each line once instead of per keyword and collects match line numbers as a pre-sorted array (no Set/sort).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Performance improvements to the search backend (P0 + P1 from the optimization review).
P0 — search core
-epatterns to a single process, scanning the tree once.rgSearchArgsaccepts a keyword array; using-ealso protects patterns starting with-.P1 — filename search + preview
Promise.all) to overlap filesystem I/O instead of one scan per keyword.fs.promises.readFile) so the main process is no longer blocked on large files.Testing
npm test— all 5 self-tests pass.